package top.code.common.utils;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间的工具类 2017/9/25.
 */
public class DateUtils {
    private static Calendar calendar = Calendar.getInstance();
    /**
    *@Author benson {www.honey520.com}
    *@Date 2017/9/25 20:27
    *@Description 得到周几
    */
    public static int getTodayWeek(){
        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        if (week < 0 ) week =7;
        return week;
    }

    /**
    *@Author benson {www.honey520.com}
    *@Date 2017/9/25 20:28
    *@Description 计算时间差  1000*60=1h  (end-start)/(1000*60)获取时间差
    */
    public static int getMunite(Date startDate, Date endDate){
        long start = startDate.getTime();
        long end = endDate.getTime();
        int munite = (int) ((end-start)/(1000*60));
        return munite;
    }
    /**
    *@Author benson {www.honey520.com}
    *@Date 2017/9/26 9:13
    *@Description 获得当天的某个时间
    */
    public static Date getDate(int hour,int munite){
        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,munite);
        return calendar.getTime();
    }


}
